package com.huayue.dao;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.huayue.entity.RoomPredictOrderDetails;
import com.huayue.util.PageHelper;
import com.mysql.DBHelper;

/**
 * 预定单详情
 */
@Component
public class RoomPredictOrderDetailsDao implements BaseDao<RoomPredictOrderDetails> {
    @Override
    public int insert(RoomPredictOrderDetails entity) {
        return DBHelper.executeUpdate(
            "insert into room_predict_order_details(room_predict_order_id,room_type_id,room_id,price) values((select Max(id) from room_predict_order),?,?,?)",
            entity.getRoomTypeId(), entity.getRoomId(), entity.getPrice());
    }

    @Override
    public int update(RoomPredictOrderDetails entity) {
        return 0;
    }

    @Override
    public int delete(RoomPredictOrderDetails entity) {
        return 0;
    }

    @Override
    public List<Map<String, Object>> findAll(Object... obj) {
        return null;
    }

    @Override
    public List<Map<String, Object>> findPage(PageHelper page, Object... obj) {
        return null;
    }

    @Override
    public Map<String, Object> findOne(RoomPredictOrderDetails entity) {
        return null;
    }

    @Override
    public int count(Object... obj) {
        return 0;
    }

    public List<Map<String, Object>> findDetails(String id) {
        return DBHelper.executeQuery(
            "select rpod.*,rt.price rtprice from  room_predict_order_details rpod left join room_type rt on rpod.room_type_id=rt.id where rpod.is_deleted=0 and rpod.room_predict_order_id=?",
            id);
    }
}
